#define F(a,b,c) for(ll a=b;a<=(c);a++)
#define f(a,b,c) for(ll a=b;a>=(c);a--)
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
namespace LDY_NAMESPACE{
    const ll N=1111111;
    ll sum[N],pos[N],sig,l[N],r[N],dp[N],ans0,ans,lenth;
    bool is[N];
    ll T,n,m,len,v;
    ll td[N],tv[N],ta[N];
    pair<ll,ll>over[N];
    void THE_REAL_MAIN(){
        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
        cin>>T;
        while(T--){
            memset(l,0,sizeof l);
            memset(r,0,sizeof r);
            memset(sum,0,sizeof sum);
            memset(dp,0,sizeof dp);
            memset(pos,0,sizeof pos);
            ans=ans0=0;
            cin>>n>>m>>len>>v;
            F(i,1,n){
                cin>>td[i]>>tv[i]>>ta[i];

            }
            F(i,1,m){
                ll t;
                cin>>t;
                is[t]=1;
            }
            F(i,1,len){
                if(is[i]) pos[++sig]=i,l[i]=sig-1,r[i]=sig+1;
                else{
                    l[i]=sig,r[i]=sig+1;
                }
                sum[i]=sum[i-1]+is[i];
            }
            F(i,1,n){
                if(ta[i]>0){
                    if(tv[i]>v){
                        if(r[td[i]-1]<=sig){
                            over[++lenth]={r[td[i]-1],sig},ans0++;
                        }
                    }
                    else{
                        double ds=(v*v-tv[i]*tv[i])/(2*ta[i]);
                        ll s=ceil(ds);
                        if(r[td[i]+s]<=sig){
                            over[++lenth]={r[td[i]+s],sig},ans0++;
                        }
                    }
                }else if(ta[i]==0){
                    if(tv[i]>v){
                        if(r[td[i]-1]<=sig){
                            over[++lenth]={r[td[i]-1],sig},ans0++;
                        }
                    }
                }else{
                    if(tv[i]>v){
                        double ds=(v*v-tv[i]*tv[i])/(2*ta[i]);
                        ll s=ceil(ds);
                        //cout<<r[td[i]-1]<<' '<<l[min(td[i]+s,len)]<<endl;
                        if(r[td[i]-1]<=l[min(td[i]+s,len)]){
                            over[++lenth]={r[td[i]-1],l[min(td[i]+s,len)]},ans0++;
                        }
                    }
                }
            }
            sort(over+1,over+lenth+1);
            ll last=0;
            F(i,1,lenth){
                ll x1=over[i].first,x2=over[i].second;
                if(x1<=x2){
                    if(x1>last){
                        F(j,x1,x2) dp[j]=1;
                        last=x2;
                    }
                    else if(x2<over[i+1].first||i==lenth){
                        ll temp=100000000;
                        F(j,x1,x2) temp=min(temp,dp[j]);
                        ans+=temp;
                    }else{
                        F(j,last+1,x2) dp[j]=dp[x1]+1;
                        last=x2;
                    }
                }
                //cout<<ans<<endl;
            }
            cout<<ans0<<' '<<m-ans<<endl;
        }
    }
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    LDY_NAMESPACE::THE_REAL_MAIN();
    return 0;
}
